﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RealWorldObjects
{
    class Student
    {
        public string name;
        public string lastName;
        public DateTime dateOfBirth;
        public List<int> marks = new List<int>();
        public int studentID;
        public double averageMark;

        public void PrintStudentMarksToConsole()
        {
            foreach (var mark in marks)
            {
                Console.WriteLine(mark);
            }
        }
        public double CalculateAverageMark()
        {
            return marks.Average();
        }
        public static Random rndStudentGenerator = new Random();
        public static int studentCount;
        public void GenerateRandomStudentInfo()
        {
            name = "Vasya";
            lastName = "Pupkin";
            dateOfBirth = new DateTime(Student.rndStudentGenerator.Next(1990,2012), Student.rndStudentGenerator.Next(1,13), Student.rndStudentGenerator.Next(1,29));
            for (int i = 0; i<5; i++)
            {
                int mark = Student.rndStudentGenerator.Next(1, 101);
                marks.Add(mark);
            }
        }
        public static Student GenerateRandomStudent()
        {
            Student.studentCount++;
            Student student = new Student();
            student.studentID = studentCount;
            student.name = "Vasya";
            student.lastName = "Pupkin";
            student.dateOfBirth = new DateTime(Student.rndStudentGenerator.Next(1990, 2012), Student.rndStudentGenerator.Next(1, 13), Student.rndStudentGenerator.Next(1, 29));
            for (int i = 0; i<5; i++)
            {
                int mark = Student.rndStudentGenerator.Next(1, 101);
                student.marks.Add(mark);
            }
            student.averageMark = student.marks.Average();
            return student;
        }
        public void PrintStudentInfoToConsole()
        {
            Console.WriteLine("Student {0}: {1} {2} ({3}); Average mark: {4}", studentID, name, lastName,dateOfBirth.ToString("dd/MM/yyy"), averageMark );
        }
    }
}
